package org.laobai.permission.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.laobai.permission.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jiusan
 * @since 2021-11-17
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("SELECT\n" +
            "a.*,CONCAT(b.`name`,'-',c.name,'-',d.name) as location\n" +
            "FROM\n" +
            "t_user a\n" +
            "LEFT JOIN t_area b ON a.province = b.id\n" +
            "LEFT JOIN t_area c ON a.city = c.id\n" +
            "LEFT JOIN t_area d ON a.district = d.id" +
            " ${ew.customSqlSegment}")
    Page<User> getPage(Page<User> userPage, @Param("ew") QueryWrapper<User> wrapper);
}
